]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspaceThumbnails: Center thumbnails in workspace navigator
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 1 Feb 2021 15:28:49 +0000 (16:28 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 1 Feb 2021 15:34:37 +0000 (16:34 +0100)
We always request a natural width based on the maximum thumbnail scale,
but may very well use a smaller scale when allocating. This currently
results in thumbnails being off center, fix this by distributing any
extra space evenly before allocating thumbnails.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1620>

js/ui/workspaceThumbnail.js

index 73f25593bd8d912070fed69582ebe6c7aaf4be4b..46de36fa47f0c386d7176b22a9d5e28cb261bd51 100644 (file)
@@ -1302,6 +1302,13 @@ var ThumbnailsBox = GObject.registerClass({
         const thumbnailWidth = Math.round(thumbnailHeight * ratio);
         const roundedVScale = thumbnailHeight / portholeHeight;
 
+        // We always request size for MAX_THUMBNAIL_SCALE, distribute
+        // space evently if we use smaller thumbnails
+        const extraWidth =
+            (MAX_THUMBNAIL_SCALE * portholeWidth - thumbnailWidth) * nWorkspaces;
+        box.x1 += Math.round(extraWidth / 2);
+        box.x2 -= Math.round(extraWidth / 2);
+
         let indicatorValue = this._scrollAdjustment.value;
         let indicatorUpperWs = Math.ceil(indicatorValue);
         let indicatorLowerWs = Math.floor(indicatorValue);